home *** CD-ROM | disk | FTP | other *** search
- head 1.8;
- access;
- symbols
- VER_0_3:1.8
- VER_0_2:1.7;
- locks; strict;
- comment @ * @;
-
-
- 1.8
- date 95.03.24.11.44.17; author coulter; state Exp;
- branches;
- next 1.7;
-
- 1.7
- date 95.03.10.02.43.06; author coulter; state Exp;
- branches;
- next 1.6;
-
- 1.6
- date 95.02.19.17.15.09; author coulter; state Exp;
- branches;
- next 1.5;
-
- 1.5
- date 95.02.18.09.21.50; author coulter; state Exp;
- branches;
- next 1.4;
-
- 1.4
- date 95.02.14.21.39.21; author coulter; state Exp;
- branches;
- next 1.3;
-
- 1.3
- date 95.02.14.20.22.40; author coulter; state Exp;
- branches;
- next 1.2;
-
- 1.2
- date 95.02.13.20.56.00; author coulter; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 95.02.11.13.14.47; author coulter; state Exp;
- branches;
- next ;
-
-
- desc
- @Define iso_ioctl. Will define ioctl commands for logging.
- @
-
-
- 1.8
- log
- @Checkin version for 0.3 distribution.
- @
- text
- @/*
- * linux/fs/isofs/ioctl.c - ioctl stuff to log operations
- *
- * (C) Copyright 1995 by Michael Coulter. All rights reserved.
- *
- */
-
- #include <asm/segment.h>
-
- #include <linux/errno.h>
- #include <linux/fs.h>
- #include <linux/iso_fs.h>
- #include <linux/ioctl.h>
- #include <linux/kernel.h>
- #include <linux/malloc.h>
- #include <linux/sched.h>
-
- /****************************************************************************
- Local defines for logging:
- ISO_LOG_MALLOC_LIMIT largest region obtainable from kmalloc()
- ISO_LOG_ENTRIES_PER_BUF The number of log entries that fit in a buffer.
- ISO_LOG_NBR_LOG_BUFS The number of ISO_LOG_MALLOC_LIMIT size buffers
- to allocate to hold log information.
- ISO_LOG_SIZE Size of memory passed to user. iso_log_info
- plus space for all the buffers.
- ****************************************************************************/
-
- /* Define ISO_LOG_MALLOC_LIMIT for use in another define */
- #define ISO_LOG_MALLOC_LIMIT 4096
-
-
-
- #define ISO_LOG_ENTRIES_PER_BUF ( ISO_LOG_MALLOC_LIMIT \
- / sizeof(struct iso_log_entry))
- #define ISO_LOG_NBR_LOG_BUFS 10
- #define ISO_LOG_SIZE ( sizeof(struct iso_log_info) \
- + ( ISO_LOG_NBR_LOG_BUFS \
- * ISO_LOG_MALLOC_LIMIT))
-
- /****************************************************************************
- Data declarations
- ****************************************************************************/
-
- static struct iso_log_info iso_log_pass;
- static int iso_overflow_count;
-
- static int log_buf_index;
- static int iso_log_is_active = 1;
- static struct iso_log_entry* log_buffers[ISO_LOG_NBR_LOG_BUFS];
-
- /* If first_log_p is NULL, iso_initialize_log must be called. */
-
- static struct iso_log_entry* first_log_p = NULL;
- static struct iso_log_entry* limit_log_p;
- static struct iso_log_entry* next_log_p;
-
- /****************************************************************************
- iso_stop_log - stop logging. Free log buffers.
- ****************************************************************************/
-
- static void iso_stop_log(void) {
- int idx;
-
- iso_log_is_active = 0;
- if (first_log_p == NULL) {
- return; /* Nothing to free */
- }
- for (idx = 0; idx < ISO_LOG_NBR_LOG_BUFS; idx++) {
- kfree_s(log_buffers[idx], ISO_LOG_MALLOC_LIMIT);
- }
- first_log_p = NULL;
- } /* end iso_stop_log */
-
-
-
- /****************************************************************************
- iso_initialize_log: Initialize logging. Allocate log buffers
- Return TRUE if success.
- ****************************************************************************/
-
- static int iso_initialize_log(void)
- {
- int idx;
-
- /* Define entire array of log_buffers in case we must bail out and
- ** call iso_stop_log.
- */
- for (idx = 0; idx < ISO_LOG_NBR_LOG_BUFS; idx++) {
- log_buffers[idx] = NULL;
- }
- for (idx = 0; idx < ISO_LOG_NBR_LOG_BUFS; idx++) {
- if ( (log_buffers[idx] = (struct iso_log_entry*)
- kmalloc(ISO_LOG_MALLOC_LIMIT, GFP_KERNEL))
- == NULL)
- {
- first_log_p = log_buffers[0];
- iso_stop_log();
- return 0; /* Failure to initialize log */
- }
- }
- log_buf_index = 0;
- iso_overflow_count = 0;
- first_log_p = log_buffers[0];
- next_log_p = first_log_p;
- limit_log_p = first_log_p + ISO_LOG_ENTRIES_PER_BUF;
- iso_log_is_active = 1;
- return 1; /* success, TRUE */
- } /* end iso_initialize_log */
-
-
- /****************************************************************************
- next_buffer - Move first_log_p to the next buffer.
- ****************************************************************************/
- static void next_buffer(void)
- {
- log_buf_index++;
- if (log_buf_index >= ISO_LOG_NBR_LOG_BUFS) {
- iso_overflow_count++;
- log_buf_index = 0;
- }
- first_log_p = log_buffers[log_buf_index];
- next_log_p = first_log_p;
- limit_log_p = first_log_p + ISO_LOG_ENTRIES_PER_BUF;
- } /* end next_buffer */
-
-
- /****************************************************************************
- iso_ioctl - Routine to handle ioctl calls.
- ****************************************************************************/
-
- int iso_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
- unsigned long arg)
- {
- switch (cmd) {
- case ISO_IOC_GETLOGSIZE :
- if (first_log_p == NULL) {
- iso_initialize_log();
- }
- return ISO_LOG_SIZE;
-
- case ISO_IOC_READLOG :
- return iso_log_read(inode, (void *) arg);
-
- case ISO_IOC_STOPLOG :
- iso_stop_log();
- return 0;
-
- default:
- return -EINVAL;
- }
- return -EINVAL;
- } /* end iso_ioctl */
-
-
- /****************************************************************************
- iso_log_add - Add an entry to the log
- ****************************************************************************/
-
- void iso_log_add(unsigned long inode, dev_t i_dev, int operation) {
- if (! iso_log_is_active) {
- return;
- }
- if (first_log_p == NULL) {
- if (!iso_initialize_log()) {
- return;
- }
- }
- if (next_log_p == limit_log_p) {
- next_buffer(); /* Move pointers to the next (or first) buffer */
- }
- next_log_p->inode = inode;
- next_log_p->operation = operation;
- next_log_p->device = i_dev;
- next_log_p++;
- } /* end iso_log_add */
-
-
- /****************************************************************************
- iso_log_read - return the buffer to the caller. Empty the log.
- ****************************************************************************/
- int iso_log_read(struct inode * inode, void* user_buf_p)
- {
- struct iso_log_entry* from_ptr;
- int idx;
- struct iso_log_entry* to_ptr;
- struct iso_log_info* user_ptr;
-
- if (first_log_p == NULL) {
- if (!iso_initialize_log()) {
- return -ENOMEM;
- }
- }
- iso_log_pass.version = ISO_LOG_VERSION;
- iso_log_pass.buf_format = ISO_LOG_BUF_FORMAT1;
- iso_log_pass.size = ISO_LOG_SIZE;
- iso_log_pass.device = inode->i_dev;
- iso_log_pass.overflow_count = iso_overflow_count;
- iso_log_pass.nbr_entries = next_log_p - first_log_p
- + (ISO_LOG_ENTRIES_PER_BUF * log_buf_index);
-
- memcpy_tofs(user_buf_p, &iso_log_pass, sizeof(struct iso_log_info));
-
- /* Now copy the log buffers */
-
- user_ptr = (struct iso_log_info*) user_buf_p;
- to_ptr = &(user_ptr->log_entry[0]);
- for (idx = 0; idx < ISO_LOG_NBR_LOG_BUFS; idx++) {
- from_ptr = log_buffers[idx];
- memcpy_tofs(to_ptr,
- from_ptr,
- ISO_LOG_ENTRIES_PER_BUF * sizeof(struct iso_log_entry));
- to_ptr += ISO_LOG_ENTRIES_PER_BUF;
- }
-
- /* reset log */
-
- log_buf_index = ISO_LOG_NBR_LOG_BUFS - 1;
- next_buffer();
- iso_overflow_count = 0;
-
- return 0;
- } /* end iso_log_read */
-
-
- /****************************************************************************
- log_generic_mmap - possibly log calls to generic_mmap
- ****************************************************************************/
-
- int log_generic_mmap(struct inode * inode,
- struct file * file,
- struct vm_area_struct * vm_area)
- {
- /* Reduce log volume by not logging this. it is
- ** always? preceeded by other ops.
- */
- /* iso_log_add(inode->i_ino, inode->i_dev, ISO_LOG_OP_generic_mmap); */
- return generic_mmap(inode, file, vm_area);
- } /* end log_generic_mmap */
-
- @
-
-
- 1.7
- log
- @Checkin files modified to make version 0.2
- @
- text
- @d3 2
- @
-
-
- 1.6
- log
- @Added code to map generic_mmap. Commented out for now.
- @
- text
- @d140 1
- a140 1
- return iso_log_read((void *) arg);
- d157 1
- a157 1
- void iso_log_add(unsigned long inode, int operation) {
- d171 1
- d179 1
- a179 1
- int iso_log_read(void* user_buf_p)
- d194 1
- d234 1
- a234 1
- /* iso_log_add(inode->i_ino, ISO_LOG_OP_generic_mmap); */
- @
-
-
- 1.5
- log
- @Checkin version 0.1, size, get log, stop
- @
- text
- @d219 17
- @
-
-
- 1.4
- log
- @Checkpoint files to send to isofs owners.
- @
- text
- @d64 1
- a64 1
- return; /* Nothing to stop */
- @
-
-
- 1.3
- log
- @Checkpoint working dynamic log version.
- @
- text
- @d16 27
- a42 1
- static struct iso_log_info iso_log_info;
- d55 3
- a57 1
- /* Stop logging. Free allocated log buffers. */
- d73 5
- a77 1
- /* Initialize logging. Allocate log buffers Return TRUE if success. */
- d108 4
- a111 1
- /* Move first_log_p to the next buffer. */
- d124 4
- a127 1
- /* Routine to handle ioctl calls */
- d152 4
- a155 1
- /* Add an entry to the log */
- d174 4
- d190 5
- a194 5
- iso_log_info.version = ISO_LOG_VERSION;
- iso_log_info.buf_format = ISO_LOG_BUF_FORMAT1;
- iso_log_info.size = ISO_LOG_SIZE;
- iso_log_info.overflow_count = iso_overflow_count;
- iso_log_info.nbr_entries = next_log_p - first_log_p
- d197 1
- a197 1
- memcpy_tofs(user_buf_p, &iso_log_info, sizeof(struct iso_log_info));
- @
-
-
- 1.2
- log
- @Checkin working version. Try to make it dynamic now.
- @
- text
- @d12 2
- d17 1
- a17 1
- static int iso_overflow_count = 0;
- d19 3
- a21 4
- static struct iso_log_entry* first_log_p = &iso_log_info.log_entry[0];
- static struct iso_log_entry* limit_log_p = &iso_log_info
- .log_entry[ISO_LOG_MAX_ENTRIES];
- static struct iso_log_entry* next_log_p = &iso_log_info.log_entry[0];
- d23 65
- d94 19
- a112 11
- switch (cmd) {
- case ISO_IOC_GETLOGSIZE :
- return sizeof(struct iso_log_info);
-
- case ISO_IOC_READLOG :
- return iso_log_read((void *) arg);
-
- default:
- return -EINVAL;
- }
- }
- d117 8
- d126 1
- a126 3
- /* No more room, reset log */
- iso_overflow_count++;
- next_log_p = first_log_p;
- d135 10
- d146 2
- a147 1
- iso_log_info.size = sizeof(iso_log_info);
- d149 2
- a150 1
- iso_log_info.nbr_entries = next_log_p - first_log_p;
- d153 19
- a171 1
- next_log_p = first_log_p; /* reset log */
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d2 1
- a2 1
- * linux/fs/isofs/ioctl.c
- d14 11
- a27 3
- int err;
- unsigned long flags;
-
- d29 2
- a30 2
- case ISO_IOC_GETLOGSIZE:
- return 1492;
- d33 1
- a33 1
- return -EINVAL;
- d39 25
- @
-